package com.zzt.blog.common.util;

import com.zzt.blog.pojo.dataobject.BlogInfo;
import com.zzt.blog.pojo.dataobject.UserInfo;
import com.zzt.blog.pojo.request.UpdateBlogRequest;
import com.zzt.blog.pojo.response.BlogInfoResponse;
import com.zzt.blog.pojo.response.UserInfoResponse;
import org.springframework.beans.BeanUtils;

/**
 * Created with IntelliJ IDEA.
 * Description
 * User: panda
 * Date: 2025-04-06
 * Time: 14:35
 */
public class BeanTransUtils {
    public static BlogInfoResponse trans(BlogInfo blogInfo){
        //TODO 待做事项
        if(blogInfo == null){
            return null;
        }
        BlogInfoResponse response = new BlogInfoResponse();
        BeanUtils.copyProperties(blogInfo, response);
        return response;
    }

    public static UserInfoResponse trans(UserInfo userInfo){
        //TODO 待做事项
        if(userInfo == null){
            return null;
        }
        UserInfoResponse userInfoResponse = new UserInfoResponse();
        BeanUtils.copyProperties(userInfo, userInfoResponse);
        return userInfoResponse;
    }

    public static BlogInfo trans(UpdateBlogRequest request){
        if(request == null){
            return null;
        }
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(request, blogInfo);
        return blogInfo;
    }
}
